//
//  PhotoCollectionView.m
//  Movie
//
//  Created by tengyang on 15/7/23.
//  Copyright (c) 2015年 tengyang. All rights reserved.
//

#import "PhotoCollectionView.h"
#import "PhotoCollectionViewCell.h"

@implementation PhotoCollectionView

- (id)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout
{
    self=[super initWithFrame:frame collectionViewLayout:layout];
    if (self) {
        self.dataSource=self;
        self.delegate=self;
        [self registerClass:[PhotoCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
        
        self.pagingEnabled=YES;
    }
    return self;
}

//次方法则实现了，在放大后，下次再滑动到此图片时回复原状
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
    PhotoCollectionViewCell *cell1=(PhotoCollectionViewCell *)cell;
    PhotoScrollView *scrollView=(PhotoScrollView *)[cell1.contentView viewWithTag:100];
    scrollView.zoomScale=1;
}

- (void)setImageUrl:(NSMutableArray *)imageUrl
{
    _imageUrl=imageUrl;
    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    PhotoCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.urlStr=_imageUrl[indexPath.row];
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _imageUrl.count;
}

@end
